]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
screencastService: Create directory if it doesn't exist
authorIvan Molodetskikh <yalterz@gmail.com>
Fri, 17 Dec 2021 07:17:35 +0000 (10:17 +0300)
committerMarge Bot <marge-bot@gnome.org>
Fri, 14 Jan 2022 18:42:47 +0000 (18:42 +0000)
Instead of testing if the videos directory exists and using the home
directory otherwise, just try to create the target directory. This
aligns with how the screenshot UI handles the screenshots folder, and
it's convenient for putting screencasts into a subdirectory.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2102>

js/dbusServices/screencast/screencastService.js

index 708a15c84e6be2134d824e5a4e6fd90df35fa63d..069b00d1a9d66d91babf16602fd9ef8a931f2129 100644 (file)
@@ -58,6 +58,14 @@ var Recorder = class {
         this._height = height;
         this._filePath = filePath;
 
+        try {
+            const dir = Gio.File.new_for_path(filePath).get_parent();
+            dir.make_directory_with_parents(null);
+        } catch (e) {
+            if (!e.matches(Gio.IOErrorEnum, Gio.IOErrorEnum.EXISTS))
+                throw e;
+        }
+
         this._pipelineString = DEFAULT_PIPELINE;
         this._framerate = DEFAULT_FRAMERATE;
         this._drawCursor = DEFAULT_DRAW_CURSOR;
@@ -287,9 +295,6 @@ var ScreencastService = class extends ServiceImplementation {
             return filename;
 
         let videoDir = GLib.get_user_special_dir(GLib.UserDirectory.DIRECTORY_VIDEOS);
-        if (!GLib.file_test(videoDir, GLib.FileTest.EXISTS))
-            videoDir = GLib.get_home_dir();
-
         return GLib.build_filenamev([videoDir, filename]);
     }